﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace WindowsFormsApp2.JiayuModelset
{
    [Serializable]
    public class Chazhens_C
    {
        // public int num;
        [TypeConverter(typeof(ExpandableObjectConverter))]
        public List<Chazhenone_C> chazhens { get; set; } = new List<Chazhenone_C>();
        //提供排序方法，沿着x排序，或沿着y排序

        public int num { get { if (chazhens == null) return 0; else return chazhens.Count; } } 
        
        public void paixu(int fanfa)
        {
            if (chazhens.Count == 0)
                return;
            if (fanfa == 1)
            {
                chazhens.Sort(SortItemxy);
            }
            else
            {
                chazhens.Sort(SortItemyx);
            }
        }
        //先按x排序，再按y排序，由于是有误差，x在1.5mm范围内不做前后顺序调换，按y进行顺序调换
        //
        int SortItemxy(Chazhenone_C item1, Chazhenone_C item2)
        {

            try
            {            
                if (item1.x_mm_r > item2.x_mm_r)
                {
                    return -1;
                }else if(item1.x_mm_r == item2.x_mm_r)
                {
                    return 0;
                }
                else
                {
                    return 1;
                }
            }
            catch (Exception ex)
            {

                return 1;
            }

        }
        int SortItemyx(Chazhenone_C item1, Chazhenone_C item2)
        {
            //传入的对象为列表中的对象
            //进行两两比较，用左边的和右边的 按条件 比较
            //返回值规则与接口方法相同
            try
            {
                if (item1.y_mm_r>item2.y_mm_r)
                {
                    return -1;
                }
                else if (item1.y_mm_r == item2.y_mm_r)
                {
                    return 0;
                }
                else
                {
                    return 1;
                }
            }
            catch (Exception)
            {

                return 1;
            }
        }

      
    }

    [Serializable]
    public class ChazhenY_C
    {
        public int ID { get; set; } = 0;
        public int K_type { get; set; } = 0;
        public double X { get; set; } = 0;
        public double Y { get; set; } = 0;
        public double R { get; set; } = 0;
        public double dispX { get; set; } = 0;
        public double dispY { get; set; } = 0;
        public int State { get; set; } = 0;
    }
    [Serializable]
    public class Chazhen_Det_reslut_C
    {
        public int ID { get; set; } = 0;
        public int K_type { get; set; } = 0;
        public double X { get; set; } = 0;
        public double Y { get; set; } = 0;
        public double R { get; set; } = 0;
        public Boolean OKNG { get; set; } = true;
    }
}
